package de.ff7rl.core.party;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import de.ff7rl.core.effects.Item;
import de.ff7rl.core.reference.ItemReference;

public class Party {

  public static final Party INITIAL_PARTY;

  static {
    INITIAL_PARTY = new Party();
    for (final Actor actor : Actor.values()) {
      final PartyMember partyMember = new PartyMember();
      partyMember.setName(actor.getDefaultName());
      if (actor == Actor.Cloud) {
        partyMember.setVisible(true);
        partyMember.setName("EX-Soldier");
      }
      INITIAL_PARTY.getParty().add(partyMember);
    }
    INITIAL_PARTY.addItem(ItemReference.getItem("Potion"), 3);
  }

  private final Set<PartyMember> partyMembers = new HashSet<PartyMember>();
  private final Map<Item, Integer> items = new HashMap<Item, Integer>();

  public void addItem(final Item theItem, final int theCount) {
    int newCount = theCount;
    if (items.containsKey(theItem)) {
      final int oldCount = items.get(theItem);
      newCount += oldCount;
    }
    items.put(theItem, newCount);
  }

  public Map<Item, Integer> getItems() {
    return items;
  }

  public Set<PartyMember> getParty() {
    return partyMembers;
  }

}
